package com.xzr.yespaper.service;

import com.xzr.yespaper.bean.Comment;
import com.xzr.yespaper.mapper.CommentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentService {

    @Autowired
    CommentMapper commentMapper;

    /**
     * 根据论文id得到该论文的评论 Get comment by paper id
     * @param pid Long 论文id (paper id)
     * @return List<Comment>
     */
    public List<Comment> getCommentByPaperID(Long pid){
        return commentMapper.getByPaper(pid);
    }

    /**
     * 创建评论 Create comment
     * @param comment com.xzr.yespaper.bean.Comment
     */
    public void creatComment(Comment comment){
        commentMapper.createByID(comment);
    }

    /**
     * 更改评论 Update comment
     * @param comment com.xzr.yespaper.bean.Comment
     */
    public void updateCommentByID(Comment comment){
        commentMapper.updateByID(comment);
    }

    /**
     * 删除评论 DeleteComment
     * @param id Long 相应评论的id (comment id)
     */
    public void deleteCommentByID(Long id){
        commentMapper.deleteByID(id);
    }


}
